package top.chenfu1201.mapper.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.chenfu1201.mapper.dao.UserMapper;
import top.chenfu1201.mapper.entity.UserEntity;

import java.util.List;

@Service
public class UserServiceImpl {

    @Autowired
    private UserMapper userMapper;

    public Object queryUsers() {
        List users = this.userMapper.selectAll();
        return users;
    }

    public Object findUserById(Long userId) {
        return this.userMapper.selectByPrimaryKey(userId);
    }

    public Object addUser(UserEntity userEntity) {
        int insert = this.userMapper.insert(userEntity);
        if (insert > 0) {
            return userEntity;
        } else {
            return null;
        }
    }
}
